﻿#pragma once

#ifndef BRIDGETEST_CHEM_DEV_LAYER_H
#define BRIDGETEST_CHEM_DEV_LAYER_H

/**
*****************************************************************************
*
*
*  @file    ChemDevLayer.h
*  @brief   Ìá¹©¶ÔÍâµÄ½Ó¿ÚÃû¶¨Òå
*
*  @author  º«Ë«Î°
*  @date    20250328
*  @version V1.1.0 20250328
*----------------------------------------------------------------------------
*  @note ÀúÊ·°æ±¾  ÐÞ¸ÄÈËÔ±    ÐÞ¸ÄÈÕÆÚ    ÐÞ¸ÄÄÚÈÝ
*  @note v1.0      º«Ë«Î°      20250328     ´´½¨
*
*****************************************************************************
*/

// #include "globals.h"
// #include "ChemDevLayerControl.h"
// #include "RedisDataProcessor.h"

// µ¼³ö½Ó¿Ú
#ifdef _WIN32________
#define CHEMDEVLAYER_EXP __declspec(dllimport)
#else
#define CHEMDEVLAYER_EXP
#endif

#ifdef _WIN32________
// ÉùÃ÷µ¼³öº¯Êý

/// <summary>
/// 创建仪器方法
/// </summary>
/// <param name="nInstID">板子号</param>
/// <param name="szCmd">仪器方法路径+地址</param>
/// <param name="p">仪器方法结构体</param>
/// <returns></returns>
extern "C" CHEMDEVLAYER_EXP int32_t ChemDevLayerMethodCreateParam(int32_t nInstID, char *szCmd, LPBYTE p);

/// <summary>
/// 删除仪器方法
/// </summary>
/// <param name="nInstID">板子号</param>
/// <param name="szCmd">仪器方法路径+地址</param>
/// <returns></returns>
extern "C" CHEMDEVLAYER_EXP int32_t ChemDevLayerMethodDeleteParam(int32_t nInstID, char *szCmd);

/// <summary>
/// 编译仪器方法
/// </summary>
/// <param name="nInstID">板子号</param>
/// <param name="szCmd">仪器方法路径+地址</param>
/// <param name="p">仪器方法结构体</param>
/// <returns></returns>
extern "C" CHEMDEVLAYER_EXP int32_t ChemDevLayerMethodEditParam(int32_t nInstID, char *szCmd, LPBYTE p);

/// <summary>
/// 读取本地一起方法
/// </summary>
/// <param name="nInstID">板子号</param>
/// <param name="szCmd">仪器方法路径+地址</param>
/// <param name="p">仪器方法结构体</param>
/// <returns></returns>
extern "C" CHEMDEVLAYER_EXP int32_t ChemDevLayerMethodReadParam(int32_t nInstID, char *szCmd, LPBYTE p);

/// <summary>
/// 重命名
/// </summary>
/// <param name="nInstID">板子号</param>
/// <param name="OldName">路径+修改前的名字</param>
/// <param name="NewName">路径+修改后的名字</param>
/// <returns></returns>
extern "C" CHEMDEVLAYER_EXP int32_t ChemDevLayerMethodRenameParam(int32_t nInstID, char *OldName, char *NewName);

/// <summary>
/// 文件是否存在
/// </summary>
/// <param name="nInstID">板子号</param>
/// <param name="FileName">路径+文件名</param>
/// <returns></returns>
extern "C" CHEMDEVLAYER_EXP bool ChemDevLayerMethodFileExit(int32_t nInstID, char *FileName);

/// <summary>
/// 从gc中获取仪器方法
/// </summary>
/// <param name="nInstID">板子号</param>
/// <param name="p">仪器方法结构体</param>
/// <returns></returns>
extern "C" CHEMDEVLAYER_EXP int32_t ChemDevLayerMethodQueryParam(int32_t nInstID, LPBYTE p);

/// <summary>
/// 发送仪器方法到gc
/// </summary>
/// <param name="nInstID">板子号</param>
/// <returns></returns>
extern "C" CHEMDEVLAYER_EXP int32_t ChemDevLayerMethodSendParam(int32_t nInstID);

/// <summary>
/// 初始化
/// </summary>
/// <param name="p">ip端口和板子号结构体</param>
/// <returns></returns>
/// extern "C" CHEMDEVLAYER_EXP int32_t ChemDevLayerInit( LPBYTE p );
extern "C" CHEMDEVLAYER_EXP int32_t ChemDevLayerInit(LPBYTE p, LPBYTE pRedis);
struct tagMotherBoardInfo // 主板信息格构
{
	double InstID;		   // 板子号
	char szGCType[32];	   // 主板类型，例如 "GC1949"
	char szBackendVer[32]; // 所需要的后端版本号  后端可以根据该版本号走对应版本号的流程
};

/// <summary>
/// 连接gc
/// </summary>
/// <param name="nInstID">板子号</param>
/// <param name="p">地址结构</param>
/// <returns></returns>
extern "C" CHEMDEVLAYER_EXP int32_t ChemDevLayerConnect(int32_t nInstID, LPBYTE p);
extern "C" CHEMDEVLAYER_EXP int32_t ChemDevLayerInitGC(int32_t nInstID);
struct tagTIPPortInfo // 进样口设定值和实际值
{
	double InstID; // 板子号
	char ip[32];   // ip地址
	double Port;   // 端口
};
/// <summary>
/// 断开连接
/// </summary>
/// <param name="nInstID">板子号</param>
/// <returns></returns>
extern "C" CHEMDEVLAYER_EXP int32_t ChemDevLayerDisConnect(int32_t nInstID);

/// <summary>
/// 是否能连接通gc,注意该接口连接下就立刻断开
/// </summary>
/// <param name="p">地址结构</param>
/// <returns></returns>
extern "C" CHEMDEVLAYER_EXP int32_t ChemDevLayerCanConnectToGC(LPBYTE p);

/// <summary>
/// 开始单针
/// </summary>
/// <param name="nInstID">板子号</param>
/// <param name="nVal">nVal = -1  预运行，nVal = 0 或者 nVal < -1 阀运行， nVal > 0 使用进样器</param>
/// <param name="bMPV">是否为MPV(多位阀)进样</param>
/// <returns></returns>
extern "C" CHEMDEVLAYER_EXP int32_t ChemDevLayerInstGCStart(int32_t nInstID, BOOL bMPV, int32_t nVal, int32_t iInstMethodID);

/// <summary>
/// 结束单针
/// </summary>
/// <param name="nInstID">板子号</param>
/// <returns></returns>
extern "C" CHEMDEVLAYER_EXP int32_t ChemDevLayerInstGCStop(int32_t nInstID);
#else
struct tagMotherBoardInfo // 主板信息格构
{
	double InstID;		   // 板子号
	char szGCType[32];	   // 主板类型，例如 "GC1949"
	char szBackendVer[32]; // 所需要的后端版本号  后端可以根据该版本号走对应版本号的流程
};
struct tagTIPPortInfo // 进样口设定值和实际值
{
	double InstID; // 板子号
	char ip[32];   // ip地址
	double Port;   // 端口
};
#define ChemDevLayerMethodCreateParam(a, b, c) 0
#define ChemDevLayerMethodDeleteParam(a, b) 0
#define ChemDevLayerMethodEditParam(a, b, c) 0
#define ChemDevLayerMethodReadParam(a, b, c) 0
#define ChemDevLayerMethodRenameParam(a, b, c) 0
#define ChemDevLayerMethodFileExit(a, b) 0
#define ChemDevLayerMethodQueryParam(a, b) 0
#define ChemDevLayerMethodSendParam(a) 0
#define ChemDevLayerInit(a, b) 0
#define ChemDevLayerConnect(a, b) 0
#define ChemDevLayerInitGC(a) 0
#define ChemDevLayerDisConnect(a) 0
#define ChemDevLayerCanConnectToGC(a) 0
#define ChemDevLayerInstGCStart(a, b, c, d) 0
#define ChemDevLayerInstGCStop(a) 0
#endif

#endif
